<template>
  <div class="address">
    <div class="nav">
      <van-nav-bar title="收货地址" left-arrow @click-left="onClickLeft" />
    </div>

    <main>
      <div class="box" v-for="(item, index) in addList" :key="index">
        <div class="left">
          <div class="top">
            <h2>{{ item.name }}</h2>
            <h3>{{ item.tel }}</h3>
          </div>
          <div class="bot">
            <b v-if="item.isDefault">默认</b>
            <p>{{ item.address }}</p>
          </div>
        </div>

        <div class="rigeht">
          <router-link :to="`/infoadd/${index}`">
            <van-icon name="edit" />
          </router-link>
        </div>
      </div>
    </main>

    <footer>
      <router-link :to="`/infoadd/${(index = -1)}`">
        <van-button round block type="primary" native-type="submit"
          >+新增地址</van-button
        >
      </router-link>
    </footer>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isDefault: false,
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    // handleclick(index){
    //   this.$router.push({path:'/infoadd',query:{index}})
    // }
  },

  computed: {
    addList() {
      return this.$store.state.address.addressList;
    },
  },
};
</script>

<style src="../assets/css/address.css"  scoped>
</style>